package top.yueyazhui.vhr.controller.login;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import top.yueyazhui.vhr.bean.Response;
import top.yueyazhui.vhr.util.VerificationCode;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;

@RestController
@ApiIgnore
public class LoginController {

    @GetMapping("/login")
    public Response login() {
        return Response.error("尚未登录，请登录！");
    }

    @GetMapping("/verifyCode")
    public void verifyCode(HttpSession httpSession, HttpServletResponse httpServletResponse) throws IOException {
        VerificationCode verificationCode = new VerificationCode();
        BufferedImage image = verificationCode.getImage();
        String text = verificationCode.getText();
        httpSession.setAttribute("verify_code", text);
        VerificationCode.output(image, httpServletResponse.getOutputStream());
    }
}
